<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ include file="/WEB-INF/views/taglibs.jsp" %>
<html>
<head> <meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%-- <link rel="stylesheet" href="${js}/scrollbar/jquery.mCustomScrollbar.min.css">
<script src="${js}/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script> --%>
</head>
<body>
<div id="toolbar" >	
	<form id="list" action="list"  style="display:none;" >
	<div id="search" class="easyui-panel" title="查询条件" data-options="fit:true,collapsible:true,border:0"> 
	  <input type="hidden" id="typeId" name="typeId">
	  <table class="searchTable">
		<tr>
			<td>状态：</td>
			<td><input id="status" name="status" type="combo"></td>
			<td><button id="queryBtn" type="button" class="button">查询</button></td>
			<td><button id="clearBtn" type="button" class="button">清空</button></td>
		</tr>
				
	   </table>
	</div>
	</form>
	<div style="margin: 15px; color: #f00; font-size: 1.5em;">
		点击左侧的菜单选择父类型，可以点击“添加”按钮，添加子类型
	</div>
	<div class="operate">
		<div class="om-panel-header">类型管理列表</div>
		<div class="icon" style="right:200px;">
			<ul>
	    		<li><a href="#" onclick="showNewsTypeAdd();"><span class="menu1"></span>添加</a></li>
	    		<li><a href="#" onclick="removeRow('id');"><span class="menu11"></span>删除</a></li>
			</ul>
		</div>
	</div>
</div>
<table id="grid" data-options="fit:true,border:false"></table>

</body>
<script type="text/javascript">
$(function() {	
	 refleshTree=true;
	 IsCheckFlag = false;
     $('#grid').datagrid({   
 	    url:'list', 
 	    pageSize :10,
 		pageList : [10, 20, 30, 40, 50, 100, 200, 300, 400, 500, 1000 ],
 		striped : true,
 		//rownumbers : true,
 		pagination : true,
 		toolbar : '#toolbar',
 	    columns : [[ {width : '50', field : 'ck',checkbox:true},
 	                 {width : '100',title : '名称',field : 'name'},
 	                 {width : '200',title : '英文',field : 'englishName'},
 	                 {width : '200',title : '描述',field : 'typeDesc'},
 	                 {width : '100',title : '状态',field : 'status', formatter:function(v,r){return JSON.parse('${statusMap}')[v]}},
 	                 {width : '50',title : '排序',field : 'sort'},
 					 {width : '150',title : '操作',field : 'id',
      	                formatter:function(v,r){
      	                	var html = "<a class='osbut' href='#' onclick='openUrl(\"/type/showEdit?id="+r.id+"\",600,300);'><span class='menu13'></span>编辑</a>";
      	                		html = html+" | <a class='osbut' href='#' onclick='ajaxUrl(\"/type/delete?ids="+r.id+"\",\"是否确认删除\",\"删除成功\");'><span class='menu11'></span>删除</a>";
        	                    return html;
        	            }
 					 }]
 	    		],
 	   	    onClickCell: function (rowIndex, field, value) {
 		    	if(field == "id"){
 		    		IsCheckFlag = false;
 		    	}
 	   	       },
 	   	     onSelect: function (rowIndex, rowData) {
 	   	         if (!IsCheckFlag) {
 	   	             IsCheckFlag = true;
 	   	             $("#grid").datagrid("unselectRow", rowIndex);
 	   	         }
 	   	     },                    
 	   	     onUnselect: function (rowIndex, rowData) {
 	   	         if (!IsCheckFlag) {
 	   	             IsCheckFlag = true;
 	   	             $("#grid").datagrid("selectRow", rowIndex);
 	   	         }
 	   	     }
 	}); 
    //加载下拉树
    loadTree(); 
});
function loadTree(){
	 $('.panel.datagrid.easyui-fluid').css({position:'absolute',left:'200px'});  
	 $('body').append('<div class="treeDiv" style="display:block;"><ul id="navtree"></ul></div>');
	$('#navtree').tree({   
	    url:'tree',
	    onClick: function(node){
	    	$("#typeId").val(node.id);
      		$("#queryBtn").click();
		},
		onLoadSuccess:function(){
			$('#navtree').height($('.treeDiv').height());
			$('#navtree').find(".tree-expanded").click();
		}
	}); 
}

function showNewsTypeAdd(){
	var pid = $("#typeId").val();
	if(pid==''){		
		$.messager.alert('提示:','请在左边节点树上选择父节点！'); 
		return
	}
	showAdd('/type/showAdd?pid='+pid,600,340);
}
</script>
</html>